refactor: declare rule-id as class variable#220
Merged
Conversation
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the rule ID registration system by making id a class attribute instead of an instance attribute set via constructor parameter. The @CHECKERS.register() decorator no longer requires the rule ID argument, and instead reads it from the class attribute after registration.
Key Changes:
- Simplified the
@CHECKERS.register()decorator to remove theidparameter - Updated all checker classes (FMT001-FMT018, REF001-REF015, REC001-REC006, STR001-STR009, TIV001) to declare
idas a class attribute - Modified
CheckerRegistry._add_module()to read the rule ID from the class attribute
Reviewed Changes
Copilot reviewed 54 out of 54 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| t4_devkit/sanity/checker.py | Removed constructor that accepted id parameter; declared id as class attribute |
| t4_devkit/sanity/registry.py | Updated register() to not accept id parameter; moved group validation logic into _add_module(); updated build() to instantiate checkers without arguments |
| t4_devkit/sanity/format/base.py | Added id to docstring attributes |
| t4_devkit/sanity/format/fmt*.py | Removed id from decorator call; added id as class attribute |
| t4_devkit/sanity/record/base.py | Added id to docstring attributes |
| t4_devkit/sanity/record/rec*.py | Removed id from decorator call; added id as class attribute |
| t4_devkit/sanity/reference/base.py | Added id to docstring attributes |
| t4_devkit/sanity/reference/ref*.py | Removed id from decorator call; added id as class attribute |
| t4_devkit/sanity/structure/str*.py | Removed id from decorator call; added id as class attribute |
| t4_devkit/sanity/tier4/tiv001.py | Removed id from decorator call; added id as class attribute |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This pull request refactors the way rule IDs are assigned and registered for format checkers in the
t4_devkit.sanitymodule. Instead of passing the rule ID as an argument to the@CHECKERS.registerdecorator and the checker class constructor, each checker class now sets itsidas a class attribute. The decorator is also simplified to not require the rule ID as an argument. This makes the code more consistent and easier to maintain.Key changes include:
Refactoring rule ID assignment and registration:
Removed the
idparameter from the@CHECKERS.registerdecorator in all checker classes and instead set theidas a class attribute within each checker class, such asFMT001throughFMT018. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]Updated the
Checkerbase class to expectidas a class attribute rather than an instance attribute set in the constructor, and removed theidparameter from the constructor.Documentation improvements:
FieldTypeCheckerto document the newidclass attribute.